package com.chezhujie.www.controller.api;



import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.chezhujie.www.domain.Tclause;
import com.chezhujie.www.service.TclauseService;
import com.sys.user.base.controller.BaseController;




@Controller
@RequestMapping("clauseapi")
public class TclauseApiController extends BaseController{
	private static final Logger log = LoggerFactory.getLogger(TclauseApiController.class);
	public TclauseApiController() {
	}
  

	/**
	 * 条款内容（t_clause)详情
	 * 
	 * @param clauseId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("tclauseDetail.do")
	public void detail( @RequestParam(required =true) String type, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception{
      try {
      		Map<String, Object> param = new HashMap<String, Object>();
      		param.put("type", type);
            Tclause tclause = tclauseService.getTclauseByType(param);
            jsonResult(1, "", "获取协议详情成功", tclause, response);
            } catch (Exception e) {
            jsonResult(0, "302", "获取协议详情失败，系统异常", "", response);
   			log.error("tclause detail error:", e); 
            throw e;
   		  }

	}
	 

	

	
	 

	 

 	/***
	 * 将页面输入信息转成map
	 * 
	 * @param tclause
	 * @return
	 */	private Map<String,Object> toMap(Tclause tclause){
		Map<String,Object> map=new HashMap<String, Object>();
      		if(tclause.getClauseId()!=null&&!tclause.getClauseId().equals("")){
			map.put("clauseId", tclause.getClauseId());
		}
		if(tclause.getType()!=null&&!tclause.getType().equals("")){
			map.put("type", tclause.getType());
		}
		if(tclause.getContent()!=null&&!tclause.getContent().equals("")){
			map.put("content", tclause.getContent());
		}      
		return map;
	}
   
	/**
	 * 设置页面所需的数据字典
	 * @param model
	 */
	private void setDict(ModelMap model){
		
	}



   
      
	@Resource
	private TclauseService tclauseService;


}